<?php

namespace app\admin\model;

use think\Model;

class Area extends Model
{

    // 表名
    protected $name = 'area';

    public static function getList($city_code)
    {

        $list = self::all(['CityCode'=>$city_code]);
        
        $list = collection($list)->toarray();
        
        $arr = [];
        foreach ($list as $k => $v) {
            
            $arr[$k]['Code'] = $v['Code'];
            $arr[$k]['Name'] = $v['Name'];
        }

        return $arr;
    }

    public static function getListOnearr($city_code)
    {

        $list = self::all(['CityCode'=>$city_code]);
        
        $list = collection($list)->toarray();
        
        $arr = [];
        foreach ($list as $k => $v) {
            
            $arr[$v['Code']] = $v['Name'];
            // $arr[$k]['Name'] = $v['Name'];
        }

        return $arr;
    }
}
